Skip to content

Match whole words when bolding member names in MDN comments - #2576

Open
Ngo Quoc Viet (NgoQuocViet2001) wants to merge 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-mdn-comment-bolding
Open

Ngo Quoc Viet (NgoQuocViet2001) wants to merge 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-mdn-comment-bolding

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown

The MDN comment generator bolds the first regex match of the member name, but the pattern has no word boundaries, so short names get matched inside other words. The current baselines ship comments like:

- The DOMPointReadOnl**`y`** interface's y property holds the vertical coordinate ...
+ The DOMPointReadOnly interface's **`y`** property holds the vertical coordinate ...

The same thing happens for HTMLImageElement.y and SVGMaskElement.y ("read-onl**y** y property"), for Window.top and the global top ("**topmost window") and for TextEvent.initTextEvent ("initTextEvent**Event()").

This adds \b around the name in the regex, in line with the space-delimited matching suggested in the #2171 review. Interface.name and name() matches still work. "topmost" and MDN's "initTextEventEvent()" typo have no standalone match, so those two summaries are now left unbolded. Only these comment lines change in the dom and worker baselines.

Ran:

  • npm run generate, then npm test: pass
  • npx tsgo: pass

Checked:

  • With the regenerated baselines and the old regex, node ./src/test.ts fails on the DOMPointReadOnly.y comment in dom.generated.d.ts.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR!

This section of the codebase is owned by Kagami Sascha Rosylight (@saschanaz) - if they write a comment saying "LGTM" then it will be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant